home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Clean 1.2.4 / Small Demos / revtwice.icl < prev    next >
Encoding:
Text File  |  1995-04-20  |  457 b   |  25 lines  |  [TEXT/3PRM]

  1. module revtwice
  2.  
  3. /*
  4. Reversing a list a number of times using Twice.
  5.  
  6. A list containing 25 integers is reversed 65536 times by means
  7. of four applications of the higher order function Twice.
  8. */
  9.  
  10. import StdInt, StdEnum
  11.  
  12. Revv:: [Int] -> [Int]
  13. Revv l  =  Rev l []
  14. where
  15.     Rev::[Int] [Int] -> [Int]
  16.     Rev [x:r] list    =  Rev r [x : list]
  17.     Rev []    list    =  list
  18.  
  19. Twice::(x -> x) x -> x
  20. Twice f x =  f (f x)
  21.  
  22. Start::[Int]
  23. Start = Twice Twice Twice Twice Revv [1..25]
  24.  
  25.